import ResManager from "../../../core/ResManager";
import { ResType } from "../../../net/Commond";
import { ResPath } from "../../data/CFCommon";

const { ccclass, property } = cc._decorator;

@ccclass
export default class BattleBuffIcon extends cc.Component {

    @property(cc.Label)
    labNum: cc.Label = null;

    @property(cc.Sprite)
    icon: cc.Sprite = null;

    round: number = 0;

    init(obj) {
        this.round = 1
        let icon = this.icon
        ResManager.ins().loadSingle(obj.elementIcon, ResType.image, ResPath.bufficon, (asset) => {
            icon.spriteFrame = asset
        }, this.node);
        // this.label.string = obj.round
        this.labNum.string = ''
    }

    addRound() {
        this.round++
        this.labNum.string = this.round + ""
    }

    decRound() {
        this.round--;
        this.labNum.string = this.round > 1 ? this.round + "" : ""
        if (this.round <= 0) {
            this.node.destroy()
        }
    }
}
